package com.medicine.hbp.dialog;

import com.medicine.hbp.R;

import android.app.Activity;
import android.app.Dialog;
import android.graphics.drawable.AnimationDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;

public class Loading {
	private Activity activity;
	private Dialog dialog;
	private AnimationDrawable drawable;

	public Loading(Activity activity) {
		this.activity = activity;
	}
	public void showDialog() {
		View view=LayoutInflater.from(activity).inflate(R.layout.loading, null);
		ImageView load=(ImageView) view.findViewById(R.id.img_loading);
		drawable=(AnimationDrawable) load.getBackground();
		drawable.start();
		dialog = new Dialog(activity, R.style.dialog_loading);
		dialog.addContentView(view, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		dialog.show();

	}
	public void dismissDialog() {
		drawable.stop();
		dialog.dismiss();
	}
}
